package com.wooophone.mpyeah.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.wooophone.mpyeah.dao.BrandCommentDao;
import com.wooophone.mpyeah.entity.BrandComment;
import com.wooophone.mpyeah.mapper.BrandCommentMapper;

public class BrandCommentDaoImpl implements BrandCommentDao {
	
	@Autowired
	private BrandCommentMapper brandCommentMapper;
	
	public void setBrandCommentMapper(BrandCommentMapper brandCommentMapper) {
		this.brandCommentMapper = brandCommentMapper;
	}

	@Override
	public BrandComment save(BrandComment obj) {
		brandCommentMapper.save(obj);
		return obj;
	}

	@Override
	public int update(BrandComment obj) {
		return brandCommentMapper.update(obj);
	}

	@Override
	public int delete(String id) {
		return brandCommentMapper.delete(id);
	}

	@Override
	public BrandComment get(String id) {
		return brandCommentMapper.get(id);
	}

	@Override
	public List<BrandComment> list() {
		return brandCommentMapper.list();
	}

	@Override
	public List<BrandComment> list(int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return brandCommentMapper.list();
	}

	@Override
	public int count() {
		return brandCommentMapper.count();
	}

	@Override
	public List<BrandComment> find(Map<String, Object> parameter) {
		return brandCommentMapper.listByParameter(parameter);
	}

	@Override
	public List<BrandComment> find(Map<String, Object> parameter, int offset, int limit) {
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		return brandCommentMapper.listByParameter(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return brandCommentMapper.countByParameter(parameter);
	}

	@Override
	public int count(String keyword) {
		keyword="%"+keyword+"%";
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("keyword", keyword);
		return brandCommentMapper.countByKeyword(parameter);
	}

	@Override
	public List<BrandComment> search(String keyword, int offset, int limit) {
		Map<String, Object> parameter=new HashMap<String, Object>();
		parameter.put("limit", limit);
		parameter.put("offset", offset);
		parameter.put("keyword", "%"+keyword+"%");
		return brandCommentMapper.search(parameter);
	}

	@Override
	public int usefulPlusOne(String id) {
		return brandCommentMapper.usefulPlusOne(id);
	}

	@Override
	public int uselessPlusOne(String id) {
		return brandCommentMapper.uselessPlusOne(id);
	}

	@Override
	public int deleteByBrandId(String id) {
	//	brandCommentReplyMapper.deleteByCommentId(id);
		return brandCommentMapper.deleteByBrandId(id);
	}
	
}
